package com.gangquan360.smartadmin.module.product.controller;

import java.util.List;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.gangquan360.smartadmin.common.anno.NoValidPrivilege;
import com.gangquan360.smartadmin.common.domain.PageResultDTO;
import com.gangquan360.smartadmin.common.domain.ResponseDTO;
import com.gangquan360.smartadmin.constant.SwaggerTagConst;
import com.gangquan360.smartadmin.module.product.domain.dto.ProductTagDTO;
import com.gangquan360.smartadmin.module.product.domain.dto.ProductTagQueryDTO;
import com.gangquan360.smartadmin.module.product.service.ProductTagService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * [ 产品标签表 ]
 *
 * @author wiggin
 * @version 1.0
 * @company wiggin
 * @copyright (c) 2019 wigginInc. All rights reserved.
 * @date 2020-03-14 21:33:16
 * @since JDK1.8
 */
@RestController
@Api(tags = {SwaggerTagConst.Group2.PRODUCT_TAG_MANGER})
public class ProductTagController {

    @Autowired
    private ProductTagService productTagService;

    @ApiOperation(value = "分页查询产品标签表",notes = "@author wiggin")
    @PostMapping("/product/tag/page/query")
    public ResponseDTO<PageResultDTO<ProductTagDTO>> queryByPage(@RequestBody ProductTagQueryDTO queryDTO) {
        return productTagService.queryByPage(queryDTO);
    }
    
    @ApiOperation("获取列表")
    @GetMapping("/product/tag/list")
    @NoValidPrivilege
    public ResponseDTO<List<ProductTagDTO>> queryList() {
    	return productTagService.queryList();
    }

    @ApiOperation(value = "添加产品标签表",notes = "@author wiggin")
    @PostMapping("/product/tag/add")
    public ResponseDTO<String> add(@RequestBody @Valid ProductTagDTO addTO){
        return productTagService.add(addTO);
    }

    @ApiOperation(value="修改产品标签表",notes = "@author wiggin")
    @PostMapping("/product/tag/update")
    public ResponseDTO<String> update(@RequestBody @Valid ProductTagDTO updateDTO){
        return productTagService.update(updateDTO);
    }


    @ApiOperation(value="删除产品标签表",notes = "@author wiggin")
    @GetMapping("/product/tag/delete/{id}")
    public ResponseDTO<String> delete(@PathVariable("id") Long id){
        return productTagService.delete(id);
    }


    @ApiOperation(value="详情产品标签表",notes = "@author wiggin")
    @GetMapping("/product/tag/detail/{id}")
    public ResponseDTO<ProductTagDTO> detail(@PathVariable("id") Long id){
        return productTagService.detail(id);
    }
}
